var removeDuplicates = function (nums) {
    return(new Set(nums)).size
}

var removeDuplicates = function (nums) {
    if(!Array.isArray(nums)){return}
    //排序的列表直接判断和前一个值不相等就可以了
    for (let i = 0; i < nums.length; i++) {
        if (nums[i] === nums[i - 1]) {
            nums.splice(i, 1)
            i--
        }
    }
    return nums.length
}